var psTime = 30000;
var psurl;

function updatePresence() {
  $.ajax({
    url: psurl,
    type: 'GET',
    success: function(data, textStatus) {
      setTimeout("updatePresence()", psTime);
    }
  })
}

$(document).ready(function() {
  psurl = '/user/presence' + (typeof roomid == 'undefined' ? '' : '/' + roomid);
  updatePresence();
});